﻿namespace WMS6.Web.Configuration
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class VendorQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlCityOper;
        protected DropDownList ddlIsActive;
        protected DropDownList ddlIsActiveOper;
        protected DropDownList ddlVendorDescrOper;
        protected DropDownList ddlVendorIDOper;
        protected DropDownList ddlVendorNameOper;
        protected HtmlForm F2030;
        protected HtmlInputHidden hdnActionID;
        protected Label lblCity;
        protected Label lblIsActive;
        protected Label lblOwner;
        protected Label lblVendorDescr;
        protected Label lblVendorID;
        protected Label lblVendorName;
        protected HtmlLink mycss;
        protected ScriptManager ScriptManager1;
        protected TextBox txtCity;
        protected TextBox txtVendorDescr;
        protected TextBox txtVendorID;
        protected TextBox txtVendorName;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("VendorList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("VendorList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void InitDropDownLists()
        {
            base.InitQueryDDL(this.ddlVendorIDOper, 0);
            base.InitQueryDDL(this.ddlVendorDescrOper, 0);
            base.InitQueryDDL(this.ddlVendorNameOper, 0);
            base.InitQueryDDL(this.ddlCityOper, 0);
            base.InitQueryDDL(this.ddlIsActiveOper, 0);
            base.InitIsActiveDDL(this.ddlIsActive, 0);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnNew.Visible = false;
                this.btnExport.Visible = false;
                this.ddlIsActive.SelectedValue = "Y";
                this.ddlIsActive.Enabled = false;
                this.hdnActionID.Value = base.Request.QueryString["langstyle"];
                if ((base.GetValueFromAppSettings("IS_DIRECT_LIST") == "Y") && (base.Request.QueryString["from"] != "list"))
                {
                    this.btnList_Click(this.btnList, null);
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.InitDropDownLists();
                this.LoadData();
            }
        }

        public string City
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCity.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCity.Text.Trim(), this.ddlCityOper.SelectedValue);
                }
                return "";
            }
        }

        public string IsActive
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsActive.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsActive.SelectedValue, this.ddlIsActiveOper.SelectedValue);
                }
                return "";
            }
        }

        public string VendorDesc
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtVendorDescr.Text.Trim()))
                {
                    return base.GetParamsString(this.txtVendorDescr.Text.Trim(), this.ddlVendorDescrOper.SelectedValue);
                }
                return "";
            }
        }

        public string VendorID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtVendorID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtVendorID.Text.Trim(), this.ddlVendorIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string VendorName
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtVendorName.Text.Trim()))
                {
                    return base.GetParamsString(this.txtVendorName.Text.Trim(), this.ddlVendorNameOper.SelectedValue);
                }
                return "";
            }
        }
    }
}

